package gemini.castor.ui.client.page.content.account.volumepoint;

import gemini.castor.ui.client.mvp.container.CastorPlaceContainer;
import gemini.castor.ui.client.mvp.container.CastorPlaceContainer.PresenterGetter;
import gemini.castor.ui.client.mvp.container.CastorWidgetContainerDisplay;
import gemini.castor.ui.client.mvp.container.CastorWidgetContainerPresenter;
import gemini.castor.ui.client.mvp.gin.CastorGinjector;
import gemini.castor.ui.client.utils.PlaceConstants;
import ch.elca.gwt.mvp.client.EventBus;
import ch.elca.gwt.mvp.client.place.Place;
import ch.elca.gwt.mvp.client.place.PlaceRequest;

import com.google.inject.Inject;

public class VolumePointPresenter extends
		CastorWidgetContainerPresenter<VolumePointPresenter.Display> {
	
	
	public interface Display extends CastorWidgetContainerDisplay {
		
	}

	public static final Place PLACE = new CastorPlaceContainer<VolumePointPresenter>(
			PlaceConstants.PLACE_VOLUME_POINT, new PresenterGetter<VolumePointPresenter>() {
				public VolumePointPresenter getPresenter() {
					return CastorGinjector.INSTANCE.getVolumePointPresenter();
				}
			});

	@Inject
	public VolumePointPresenter(Display display, EventBus eventBus) {
		super(display, eventBus);
		addPresenter(CastorGinjector.INSTANCE.getVolumePointFormPresenter());
	}

	/*
	 * Register listeners on Display actions
	 */
	@Override
	protected void onBind() {
		super.onBind();
		showPresenter(CastorGinjector.INSTANCE.getVolumePointFormPresenter(), getDistributorCode());
	}
	
	private String getDistributorCode(){
		String result = CastorGinjector.INSTANCE.getRootPresenter().getUser().getPerson().getDistributor().getCode();
		return result;
	}

	@Override
	public Place getPlace() {
		return PLACE;
	}

	@Override
	protected void onPlaceRequest(PlaceRequest request) {
		// TODO Auto-generated method stub
	}
}
